<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="/common/taglibs.jsp" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>公司简介</title>
    <%@ include file="/common/util.jsp" %>
    <script type="text/javascript">
        $(document).ready(function () {
            // window.setInterval( "getDataPer20Min()", 1000*60*20);//没20分钟刷新一次数据
            $('#description img').css('margin-right', '40px')
            getEnergy()
            getUtilStatics()
        });

        function getEnergy() {
            $.ajax({
                type: 'POST',
                contentType: 'application/json',
                url: 'getEnergy.shtml',
                data: "",
                dataType: 'json',
                success: function (data) {
                    //最新数值赋值
                    $("#cars").text(data.indexCar);
                    $("#kWh").text(data.savePower);
                    $("#dollars").text(data.saveCost);
                    $("#CO2").text(data.indexCo2);
                },
                error: function (data) {
                }
            });
        }

        function getUtilStatics() {
            $.ajax({
                type: 'POST',
                contentType: 'application/json',
                url: 'getUtilStatic.shtml',
                data: "",
                dataType: 'json',
                success: function (data) {
                    window.setInterval(function () {
                        tick(data);
                    }, 1000 * 5);
                },
                error: function (data) {
                }
            });
        }

        //页面数字刷新用()
        function tick(unitStatistics) {
            console.log(unitStatistics)
            var unitSavePower = unitStatistics.unitSavePower;
            var unitSaveCost = unitStatistics.unitSaveCost;
            if (unitSavePower) {
                var savePower = parseFloat($("#kWh").text()) + parseFloat(unitSavePower);
                $("#kWh").text(savePower.toFixed(2));
            }
            if (unitSaveCost) {
                var saveCost = parseFloat($("#dollars").text()) + parseFloat(unitSaveCost);
                $("#dollars").text(saveCost.toFixed(2));
            }
        }

        function getDataPer20Min() {
            $.ajax({
                type: 'POST',
                contentType: 'application/json',
                url: 'getTotleData.shtml',
                data: "",
                dataType: 'json',
                success: function (data) {
                    //最新数值赋值
                    $("#cars").val(data.indexCar);
                    $("#kWh").val(data.savePower);
                    $("#dollars").val(data.saveCost);
                    $("#CO2").val(data.indexCo2);
                },
                error: function (data) {
                }
            });
        }
    </script>
</head>
<body class="main">
<div class="-frame -style -luster" id="css_container">
    <!--首页框架页眉部分↓-->
    <%@ include file="/WEB-INF/pages/inc/header.jsp" %>
    <!--首页框架页眉部分↑-->

    <div class="content">
        <!-- Left导航菜单◎开始 -->
        <%@ include file="/WEB-INF/pages/inc/leftmenu.jsp" %>
        <!-- Left导航菜单◎结束 -->

        <div class="main-mid">
            <div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a href="#">公司简介</a></div>
            <div class="css_contentDiv">
                <div class="searchDetailed  c-border-radius  b-box-shadow" style="height:300px;">
                    <%--<div style="width: 350px; float:left;"><img src="${cdnctx}/src/index/img/description.png"></div>--%>
                    <div style="" id="description">
                        ${description.companydescription}
                    </div>
                </div>
                <div class="long">
                    <div style="width:100%;height:40px;background:#f8f8f8">
                        <p style="height:40px; margin-left: 20px;font-weight: bold;font-size: 15px;color: #034c91;line-height:40px;">
                            溢德行节能计算器</p>
                    </div>
                    <div class="short" style="margin-left: 4%;">
                        <div class="cell"><img src="${cdnctx}/src/index/img/car.png"/></div>
                        <div class="cell text">
                            <p id="cars">计算中...</p>

                            <p class="bold">减少汽车尾气排放（辆）</p>
                        </div>
                    </div>
                    <div class="short">
                        <div class="cell"><img src="${cdnctx}/src/index/img/light.png"/></div>
                        <div class="cell text">
                            <p id="kWh">计算中...</p>

                            <p class="bold">节省电量（度）</p>
                        </div>
                    </div>
                    <div class="short">
                        <div class="cell"><img src="${cdnctx}/src/index/img/pig.png"/></div>
                        <div class="cell text">
                            <p id="dollars">计算中...</p>

                            <p class="bold">节省费用（元）</p>
                        </div>
                    </div>
                    <div class="short">
                        <div class="cell"><img src="${cdnctx}/src/index/img/leave.png"/></div>
                        <div class="cell text">
                            <p id="CO2">计算中...</p>

                            <p class="bold">减少CO<sub>2</sub>排放当量（吨）</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--首页框架页尾部分↓-->
    <%@ include file="/WEB-INF/pages/inc/footer.jsp" %>
    <!--首页框架页尾部分↑-->
</div>

<input type="hidden" id="carData" value="${descriptionEntity.carData }"/>
<input type="hidden" id="lightingData" value="${descriptionEntity.lightingData }"/>
<input type="hidden" id="pigData" value="${descriptionEntity.pigData }"/>
<input type="hidden" id="leavesData" value="${descriptionEntity.leavesData }"/>

<input type="hidden" id="carDataL" value="0"/>
<input type="hidden" id="lightingDataL" value="0"/>
<input type="hidden" id="pigDataL" value="0"/>
<input type="hidden" id="leavesDataL" value="0"/>
</body>
</html>